package com.klun.tjy.tjyes.client;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class ESClient {


	public static void main(String[] args) {
		get2();
	}
	public static void get2() {
		Settings settings = Settings.builder()
				.put("cluster.name", "my-application")
				.put("client.transport.ping_timeout", "6s")
				.build();
		try {
			TransportAddress localhost = new TransportAddress(InetAddress.getByName("localhost"), 9300);
			TransportClient client = new PreBuiltTransportClient(settings);
			client.addTransportAddress(localhost);
			System.out.println("success");
		} catch (UnknownHostException e) {
			System.out.println();
		}
	}
}
